/* 查询框绑定 设置*/
export const queryCols = [
    {
		type: 'xDatePicker',
		key: 'logDate',
		cfg: {
			//这个key 是为了 记忆用
			type: "date-range"
		},
		label: '更改时间',
		col: 'col-md-7',
	},

	{
		type: 'mSelect',
		key: 'module',
		cfg: {
			placeholder: '请选择模块',
			data: []
		},
		label: '模块',
		col: 'col-md-5'
	}
];

export const tableCols = [
	{
		type: "checkbox",
		$data: "apiId",
		width: '2rem',
		show:2
	},
	{
		title: "更改时间",
		$data: "logTime",
		sort: true,
		filter:true,
		show:1
	},
	{
		title: "更改类型",
		$data: "modType",
		align:"left",
		sort: true
	},
	{
		title: "ID",
		$data: "apiId",
		align:"left",
	},
	{
		title: "模块",
		$data: "module",
		align:"left",
	},
	{
		title: "接口",
		$data: "api",
		filter: true,
		align:"left"
	},
	{
		title: "权限",
		$data: "authCheckName",
		align:"left",
	},
	{
		title: "状态",
		$data: "stateName",
		filter: true,
		align:"left"
	},
	{
		title: "接口实现",
		type: "expand",
		callback: showHml
	},

	{
		title: "接口说明",
		type: "expand",

		callback: showRemark
	}
];

function renderTextarea(text) {
	let tmpl = `<div class="textarea modal-md">
                    <div data-key="head">   
                      <div data-key="line">
                      	{{lines}}
                      </div>
                      <div data-key="text">
                         <textarea readonly="readonly" wrap="hard">{{text}}</textarea>
                      </div>
                    </div>               
                </div>`;
	let tmplline = '<div data-key="number">{{num}}</div>';
	let lineHtml = "";
	let lineCount = text.split("\n").length + 1;
	for(let i = 1; i <= lineCount; i++) {
		lineHtml += tmplline.replace("{{num}}", i);
	}

	return tmpl.replace('{{lines}}', lineHtml).replace('{{text}}', '\n' + text);
}

function showHml(data) {
	return renderTextarea(data.hml);
}

function showRemark(data) {
	return renderTextarea(data.remark);
}

export const viewCols = [{
		tag: '日志时间',
		title: "更改时间",
		$data: "logTime",
		col: 'col-md-6'
	},

	{
		title: "更改类型",
		$data: "modType",
		tag: '基本信息'
	},
	{
		title: "ID",
		$data: "apiId",
		tag: '基本信息'
	},
	{
		title: "模块",
		$data: "module",
		tag: '基本信息'
	},
	{
		title: "接口",
		$data: "api",
		tag: '基本信息'
	},
	{
		title: "权限",
		$data: "authCheckName",
		tag: '基本信息'
	},
	{
		title: "状态",
		$data: "stateName",
		tag: '基本信息'
	},
	{
		type: 'text',
		title: "接口实现",
		$data: 'hml',
		col: 'col-md-12',
		tag: '实现'
	},

	{
		type: 'text',
		title: "接口说明",
		$data: 'remark',
		col: 'col-md-12',
		tag: '实现'
	}
];

export const updateBinds=[
    
	{
		type:'xDatePicker',
		label: "更改时间",
		key: "logDate",
		cfg: {			 
			type: "datetime",
			mandatory:true
		},
	},
	{
		type:'input',
		label: "更改类型",
		key: "modType" ,
		cfg: {
			type: 'checkbox',
			data: [{
				code: "insert"
			}, {
				code: "update"
			}, {
				code: "delete"
			}],
			mandatory:true,
			placeholder:'请选择更改类型'
		}		
	},
	{
		type:'input',
		label: "ID",
		key: "apiId",
		cfg:{
			type:'text',
			mandatory:true,
			placeholder:'请输入ID'
		}
		
	},
	{
		type:'input',
		label: "模块",
		key: "module",
		cfg:{
			type:'text',
			mandatory:true,
			placeholder:'请输入模块'
		}
	}
	
]
